package com.zf.zffencheng.controller.admin;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zf.zffencheng.model.Result;
import com.zf.zffencheng.model.dto.PalaceRegionFilter;
import com.zf.zffencheng.model.pojo.PalaceRegion;
import com.zf.zffencheng.model.pojo.TAdminBank;
import com.zf.zffencheng.model.vo.AccountVo;
import com.zf.zffencheng.model.vo.AdminLoginInfoVo;
import com.zf.zffencheng.model.vo.HomePageVo;
import com.zf.zffencheng.service.AccountService;
import com.zf.zffencheng.service.AdminBankService;
import com.zf.zffencheng.service.TenantPalaceRegionService;
import com.zf.zffencheng.util.UserContextUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: AdminController <br/>
 * Description:  <br/>
 * date: 2021/5/11 16:15<br/>
 *
 * @author william <br/>
 */
@Api(tags = "银行卡账号管理")
@RestController
@RequestMapping("/sapi/v1/admin/bank")
public class AdminBankController {

    @Autowired
    private AdminBankService adminBankService;

    @GetMapping("query")
    @ApiOperation("银行卡账号列表")
    public Result query(Integer page,Integer pageSize){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        Map<String, Object> map = new HashMap<>();
        map.put("list", adminBankService.listBank(currentAdminInfo.getAdminId(),page,pageSize));
        map.put("count", adminBankService.listCount(currentAdminInfo.getAdminId()));
        return Result.ok(map);
    }
    @GetMapping("get")
    @ApiOperation("银行卡账号单条数据")
    public Result get(Integer id){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        return Result.ok(adminBankService.get(id,currentAdminInfo.getAdminId()));
    }
    @PostMapping("add")
    @ApiOperation("添加银行卡账号")
    public Result addBank(@RequestBody TAdminBank adminBank){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();

        return Result.ok(adminBankService.addBank(adminBank,currentAdminInfo.getAdminId()));
    }
    @PostMapping("update")
    @ApiOperation("修改银行卡账号")
    public Result updateBank(@RequestBody TAdminBank adminBank){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        return Result.ok(adminBankService.updateBank(adminBank,currentAdminInfo.getAdminId()));
    }
    @PostMapping("del")
    @ApiOperation("删除银行卡账号")
    public Result deleteBank(Integer id){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        adminBankService.deleteBank(id,currentAdminInfo.getAdminId());
        return Result.ok();
    }
    @PostMapping("updateDefault")
    @ApiOperation("修改默认银行卡账号")
    public Result updateDefault(Integer id){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        return Result.ok(adminBankService.updateDefault(id,currentAdminInfo.getAdminId()));
    }
}
